package com.marktrace.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 * 
 */
public class RPC extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;

	public RPC() {
		put("status", 200);
	}

	public static RPC error() {
		return error(500, "未知异常，请联系管理员");
	}

	public static RPC error(String msg) {
		return error(500, msg);
	}

	public static RPC illegal(){return illegal(401,"应用请求不合法，请检查加密算法是否正确、加密密钥是否正确");}

	public static RPC error(int status, String msg) {
		RPC r = new RPC();
		r.put("status", status);
		r.put("msg", msg);
		return r;
	}

	public static RPC illegal(int status, String msg) {
		RPC r = new RPC();
		r.put("status", status);
		r.put("msg", msg);
		return r;
	}


	public static RPC ok(String msg) {
		RPC r = new RPC();
		r.put("msg", msg);
		return r;
	}

	public static RPC ok(Map<String, Object> map) {
		RPC r = new RPC();
		r.putAll(map);
		return r;
	}

	public static RPC ok() {
		return new RPC();
	}

	@Override
	public RPC put(String key, Object value) {
		super.put(key, value);
		return this;
	}

}
